#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		for (int a = 1; a <= n; a++)
		{
			printf("*");
		}
		printf("\n");
		for (int b = 2; b <= (n-1); b++)
		{
			for (int c = 1; c <= n; c++)
			{
				if (c == 1||c==n)
				{
					printf("*");
				}
				else
				{
					printf(" ");
				}
			}
			printf("\n");
		}
		for (int a = 1; a <= n; a++)
		{
			printf("*");
		}
		printf("\n");
	}
	return 0;
}